/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {string[]}
 */
var binaryTreePaths = function(root) {
    let res=[]
const path=(root,str)=>{
    if(!root)return 
    if(!root.left&&!root.right){
        str+=root.val
        res.push(str)
        return
    }
    str+=root.val+'->'
    path(root.left,str)
    path(root.right,str)
}
};